﻿/* 
 * Since 2008 - 2012
 */

package com.hh.bss.project.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

import com.hh.bss.base.*;
import com.hh.bss.common.ConstantDic;
import com.hh.bss.common.page.*;
import com.hh.bss.common.page.impl.*;
import com.hh.bss.project.dao.*;
import com.hh.bss.project.entity.*;
import com.hh.bss.project.service.*;
import com.hh.bss.project.vo.query.*;
import com.hh.bss.util.*;




@Service
@Transactional
public class ContractJobCvCrmServiceImpl extends BaseBusinessService<ContractJobCvCrm,java.lang.Integer>  implements ContractJobCvCrmService<ContractJobCvCrm,java.lang.Integer>{

	private ContractJobCvCrmDao contractJobCvCrmDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public void setContractJobCvCrmDaoImpl(ContractJobCvCrmDao dao) {
		this.contractJobCvCrmDao = dao;
	}
	private ContractJobCvRecomService contractJobCvRecomService;
	public void setContractJobCvRecomServiceImpl(ContractJobCvRecomService service) {
		this.contractJobCvRecomService = service;
	}
	public EntityDao getEntityDao() {
		return this.contractJobCvCrmDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(ContractJobCvCrmQuery query) {
		return contractJobCvCrmDao.findPage(query);
	}
	public void update(ContractJobCvCrm contractJobCvCrm){
		contractJobCvCrmDao.update(contractJobCvCrm);
		
		contractJobCvCrmDao.flush();
		ContractJobCvRecom contractJobCvRecom=new ContractJobCvRecom();
		contractJobCvRecom.setId(contractJobCvCrm.getRecomId());
		if (StringHelper.parseInteger(ConstantDic.YearOndutyStatus_SB, -1).equals(contractJobCvCrm.getOndutyStatus()))
		   contractJobCvRecom.setProjectCvStatus(SearchProjectCv.STATUS_OFFER_PASS);
		else if (StringHelper.parseInteger(ConstantDic.YearOndutyStatus_LZ, -1).equals(contractJobCvCrm.getOndutyStatus()))
		   contractJobCvRecom.setProjectCvStatus(SearchProjectCv.STATUS_OFFER_NOPASS);
		
		contractJobCvRecomService.updateRecomStatus(contractJobCvRecom);		
	}
	public void save(ContractJobCvCrm contractJobCvCrm){
		contractJobCvCrmDao.save(contractJobCvCrm);
		contractJobCvCrmDao.flush();
		ContractJobCvRecom contractJobCvRecom=new ContractJobCvRecom();
		contractJobCvRecom.setId(contractJobCvCrm.getRecomId());
		if (ConstantDic.YearOndutyStatus_SB.equals(contractJobCvCrm.getOndutyStatus()))
		   contractJobCvRecom.setProjectCvStatus(SearchProjectCv.STATUS_OFFER_PASS);
		else if (ConstantDic.YearOndutyStatus_LZ.equals(contractJobCvCrm.getOndutyStatus()))
		   contractJobCvRecom.setProjectCvStatus(SearchProjectCv.STATUS_OFFER_NOPASS);
		
		contractJobCvRecomService.updateRecomStatus(contractJobCvRecom);
		
	}
	
	
}
